package com.shuqi.model.parse.parser;

import java.util.ArrayList;
import java.util.List;

import org.xml.sax.Attributes;
import org.xml.sax.SAXException;

import com.shuqi.model.bean.CheckBookUpdateInfo;
import com.shuqi.model.parse.HandlerBase;

/**
 * 检查书籍更新:神马书籍解析 author yanghuawei
 */
public class CheckBooksUpdateSMPaser extends HandlerBase {

    private List<CheckBookUpdateInfo> list;

    @Override
    public Object getParsedData() {
        return list;
    }

    @Override
    public void startDocument() throws SAXException {
        super.startDocument();
    }

    @Override
    public void startElement(String uri, String localName, String qName, Attributes attributes)
            throws SAXException {
        if ("Books".equals(localName)) {
            list = new ArrayList<CheckBookUpdateInfo>();
        }
        if ("Book".equals(localName)) {
            CheckBookUpdateInfo info = new CheckBookUpdateInfo();
            info.setBookId(isNull(attributes, "bookId"));
            info.setBookName(isNull(attributes, "bookName"));
            info.setSourceId(isNull(attributes, "sourceId"));
            info.setMaxOid(isNull(attributes, "maxCid"));
            info.setUpdateTime(isNull(attributes, "updateTime"));
            list.add(info);
        }
    }

}
